from django.db import models
from django.contrib import admin
# Create your models here.
class Post(models.Model):
    title = models.CharField(max_length=64)
    pub_date = models.DateTimeField()
    author = models.ForeignKey('Poster')
    content = models.TextField()
    def __unicode__(self):
        return self.title
 
class Poster(models.Model):
    gender_choices = (
        ('M','Male'),
        ('F','Female')
    )
    name = models.CharField(max_length=30)
    email = models.EmailField()
    age = models.IntegerField()
    gender = models.CharField(max_length=1,choices = gender_choices)
    website = models.URLField()
    def __unicode__(self):
        return self.name
    class Meta:
        verbose_name = "Writer"
        ordering = ['age']
 
class PostAdmin(admin.ModelAdmin):
    list_display = ('title','author','pub_date')
    search_fields = ('title','author','pubdate')
 
class PosterAdmin(admin.ModelAdmin):
    list_display = ('name', 'email', 'website','gender')
    search_fields = ('name', 'email','age')
 
admin.site.register(Post, PostAdmin)
admin.site.register(Poster, PosterAdmin) 